<?php
$root        = 'E:\www\htdocs\sewiki\application';
$control_dir = $root . '\controllers';
$model_dir   = $root . '\models';
$view_dir    = $root . '\views';

$dirs = array('\controllers', '\models', '\views');
$sum  = 0;
foreach ($dirs as $dir) {
	echo $dir . "\n";
	$dir = $root . $dir;
	$handle = opendir($dir);
	while( ($file = readdir($handle)) !== false) {
		if( $file == '.' || $file == '..' || $file == '.svn')
			continue;
			
		$path = $dir . '\\' . $file;
		if( is_dir( $path ) ) {
			// echo $path;
			echo "\t|- \\" . $file . "\n";
			
			$subhandle = opendir($path);
			
			while(($file = readdir($subhandle)) !== false) {
				if( $file == '.' || $file == '..' ||  $file == '.svn')
					continue;
				
				$filepath = $path . "\\" . $file;
				$lines = count(file($filepath));
				echo "\t|\t|- " . $file . "\t(" . $lines . " lines)\n";
				$sum += $lines;
			}
		}
		else {
			$filepath = $path;
			$lines = count(file($filepath));
			echo "\t|- " . $file . "\t(" . $lines . " lines)\n";
			$sum += $lines;
		}
	}
}
echo $sum;
?>